#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

class Solution {
    public:
        string multiply(string num1, string num2) {
            reverse(num1.begin(), num1.end());
            reverse(num2.begin(), num2.end());
            int len1 = num1.size();
            int len2 = num2.size();
            string ans;
            for(int j=0; j<len2; ++j){
                for(int i=0; i<len1; ++i){
                    if(ans.size()<i+j+1){
                        ans += (num1[i]-'0')*(num2[j]-'0');
                        ans += ans[i+j]/10;
                        ans[i+j] = ans[i+j]%10;
                    }
                    else if(ans.size()==i+j+1){
                        ans[i+j] += (num1[i]-'0')*(num2[j]-'0');
                        ans += ans[i+j]/10;
                        ans[i+j] = ans[i+j]%10;
                    }
                    else {
                        ans[i+j] += (num1[i]-'0')*(num2[j]-'0');
                        ans[i+j+1] += ans[i+j]/10;
                        ans[i+j] = ans[i+j]%10;
                    }
                }
            }
            while(ans.size()>1 && ans[ans.size()-1]==0) ans.pop_back();
            for(auto& chr : ans){
                chr += '0';
            }
            reverse(ans.begin(), ans.end());
            return ans;
        }
    };

int main(){
    Solution solution;
    solution.multiply("9", "99");
}